function widget:GetInfo()
  return {
    name      = "Easy Give All",
    desc      = "Press Alt+G to call '/give all'",
    author    = "Rafal",
    date      = "Dec 2011",
    license   = "GNU GPL, v2 or later",
    layer     = 0,
    enabled   = true  --  loaded by default?
  }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local spGetGameFrame      = Spring.GetGameFrame
local spIsCheatingEnabled = Spring.IsCheatingEnabled
local spSendCommands      = Spring.SendCommands

--------------------------------------------------------------------------------

local keyCode = Spring.GetKeyCode('g')

--------------------------------------------------------------------------------

local function UpdateCallIn (name, func) 
  widget[name] = func
  widgetHandler:UpdateCallIn(name)
end

local function _Update()
  if (spIsCheatingEnabled()) then
    spSendCommands("give all")
    widgetHandler:RemoveCallIn("Update")
  end
end

function widget:KeyPress(key, modifier, isRepeat)
  if (spGetGameFrame() > 0 and key == keyCode and modifier.alt and not isRepeat) then
    if (spIsCheatingEnabled()) then
      spSendCommands("give all")
    else
      spSendCommands("cheat")
      UpdateCallIn("Update", _Update)
    end
  end
end